package com.zyf.workflow.business.fwupgrade;

import com.zyf.workflow.worker.bean.WorkerResultBean;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class PackageWorker {

    public String checkInOrOutBand(List<FwUpgradeBean> upgradeBeans, String param) {
        System.out.println("check inORoutBand start");
        String result="inBand";
//        String result="outBand";
        System.out.println("check inORoutBand end");
        return result;
    }

    public String packageIso(List<FwUpgradeBean> upgradeBeans, String param) {
//        WorkerResultBean resultBean = new WorkerResultBean();
        for (FwUpgradeBean upgradeBean : upgradeBeans) {
            System.out.println("type:" + upgradeBean.getType() + ",path:" + upgradeBean.getFilePath()
                    + ",fileName:" + upgradeBean.getFileName());
        }

        String isoName = System.currentTimeMillis() + ".iso";
        System.out.println("iso package finished.isoName is:" + isoName);
//        resultBean.setFlag(true);
//        resultBean.setData(isoName);
        return isoName;
    }


    public Map<String, String> mountIso(List<FwUpgradeBean> upgradeBeans, String isoFileName) {
        WorkerResultBean resultBean = new WorkerResultBean();
        String result = "success";
        System.out.println("iso start mount, isoName is:" + isoFileName);
        resultBean.setFlag(true);

        Map<String, String> param = new HashMap<>();
        param.put("testKey001", "testValue001");
        return param;
//        return resultBean;
    }


    public Void config(List<FwUpgradeBean> upgradeBeans, Map<String, String> param) {
//        WorkerResultBean resultBean = new WorkerResultBean();
        String result = "success";
        for (FwUpgradeBean upgradeBean : upgradeBeans) {
            Map<String, String> param1 = upgradeBean.getParam();
            if (param1 != null) {
                System.out.println("start config bmc param, param is:" + param1 + ",param is :" + param);
            }
        }


        return null;
//        resultBean.setFlag(true);
//        return resultBean;
    }


    public Void restart(List<FwUpgradeBean> upgradeBeans, String param) {
        WorkerResultBean resultBean = new WorkerResultBean();
        String result = "success";
        System.out.println("start restart server.");
        resultBean.setFlag(true);
        return null;
    }

    public Void getProcess(List<FwUpgradeBean> upgradeBeans, String param) {
        WorkerResultBean resultBean = new WorkerResultBean();

        String result = "success";

        for (int i = 0; i < 10; i++) {
            int process = (i + 1) * 10;
            System.out.println("upgrade process is:" + process);
        }
        resultBean.setFlag(true);
        return null;
    }


    public Void outBandUpgrade(List<FwUpgradeBean> upgradeBeans, String param) {

        String result = "success";

        System.out.println("outBand upgrade success");
        return null;
    }
}
